<?
/**
 * Copyright 2007 Melange.
 *
 * This file is part of PHP-MELANGE.
 *
 * PHP-MELANGE is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * PHP-MELANGE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PHP-MELANGE; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category    Melange
 * @package     php-melange
 * @subpackage  cms
 * @copyright   Copyright (c) 2007 Jeroen Simons. All rights reserved
 * @author      Jeroen Simons <jeroen@melange.nl>
 * @link        http://www.melange.nl/
 *
 */

require_once("cms/core/helper/Cacheable.php");
 
class PHP_CMS_View_Helper_Abstract extends PHP_CMS_View_Helper_Cacheable {

    /**
     * Return the directory the user has chosen to run the cms from.
     *
     * @param pageContext
     */
    protected function path() {

        $path = $this->pageContext->request->
            getContext()->getInitParameter(_Core::INCLUDE_PATH);

        $path = $path !== null ? $path . "/" : "";

        return $path;

    }

    protected function image($image) {

        // try and find the image in the view path;
        try {
            $image = $this->pageContext->_script($image);
        } catch(Exception $e) {
            ;
        }

        return $image;

    }

    protected function param($name) {

        return $this->pageContext->request->
            getContext()->getInitParameter($name);

    }

    protected function tinymce() {

        $path = $this->pageContext->request->
            getContext()->getInitParameter(_Core::TINY_MCE_PATH);

        $path = $path !== null ?
            (strrpos($path, "/") !== strlen($path) ? $path . "/" : $path) : null;

        return $path;

    }

    protected function message($key, $bundle=null, $args=null, $localeKey=null) {

        // Retrieve the message string we are looking for
        require_once("mvc/util/TagUtils.php");
        $message = TagUtils::message($this->pageContext, $bundle,
                $localeKey, $key, $args);

        return $message;

    }

}
?>